'use strict';

const Pug = require('koa-pug')
const moment = require('moment')
const {
    TARGET,
    BASE_HREF
} = require('../config')


const pug = new Pug({
    viewPath: './views',
    basedir: './views',
    debug: true,
    pretty: true,
    compileDebug: false,
    noCache: TARGET === 'development' ? true : false,

    locals: {
        APP_NAME: '数联医信',
        DESCRIPTION: '为医疗机构提供专业设备服务和专业数据服务的方案供应商',
        KEYWORDS: '医疗, 大数据, 云服务'
    },

    helperPath: [{
        DATE(date) {
            return moment(date).format('YYYY-MM-DD')
        },
        DATETIME(date) {
            return moment(date).format('YYYY-MM-DD HH:mm:ss')
        },
        AGO(date) {
            return moment(date).locale('zh-cn').fromNow()
        },
        LINK(pathname) {
            return `${BASE_HREF}/v1/${pathname}`
        },
        SS_LINK(pathname = '') {
            return `${BASE_HREF}/v1/stethoscope/${pathname}`
        },
        RO_LINK(pathname = '') {
            return `${BASE_HREF}/v1/roles/${pathname}`
        }
    }]
})


module.exports = pug